<template>
      <div class="index">
    <!-- 频道列表-->
    <van-tabs v-model="active">
      <van-tab
        v-for="channel in channels"
        :title="channel.name"
        :key="channel.id">
    <!-- 内容  -->
   <article-list :channel='channel'></article-list>
      </van-tab>
    </van-tabs>

    <!-- 文章列表 -->

  </div>
</template>

<script>
import ArticleList from './articleList.vue'
import { getChannels } from '@/api/channels.js'
export default {
  name: 'home',
  components: {
    ArticleList
  },
  data () {
    return {
      active: 0,
      channels: []
    }
  },
  created () {
    this.load()
  },
  methods: {
    async load () {
      try {
        const res = await getChannels()
        console.log(res)
        this.channels = res.data.data.channels
      } catch (err) {
        console.log(err)
        this.$toast.fail('登陆失败')
      }
    }
  }
}
</script>

<style>

</style>
